package hzau.result;

import hzau.constants.ResultConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result implements Serializable {
    private Integer code;//响应码,200 成功,300 失败
    private  String message; //相应信息 描述字符串
    private Object data;//返回的数据
    public static Result success(Object object){
        return new Result(ResultConstant.SUCCESS_CODE,ResultConstant.SUCCESS_MSG,object);
    }
    public static Result error(){
        return new Result(ResultConstant.ERROR_CODE,ResultConstant.SUCCESS_MSG,null);
    }
    public static Result error(Integer code,String msg){
        return new Result(code,msg,null);
    }
    public Result(Result result){
        this.code= result.getCode();
        this.data=result.getData();
        this.message=result.getMessage();
    }
}
